﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Web.frontStage
{
    public partial class charge : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Session["username"])
            {
                Response.Write("<script> salert ('请先登录')</script>");
                Response.Redirect("index.aspx");
            }
        }
        protected void ChargeButton_Click(object sender, EventArgs e)
        {

            if (TextBox1.Text=="")
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "MsgBox", "<script>alert('请输入充值卡号！');</script>");

            }
            else
            {//这里有session的代码
                int flag = BLL.charge.ChargeManager.Charge(Session["username"].ToString(), TextBox1.Text);
                if (flag == 0)
                {
                    Server.Transfer("chargeSuccess.aspx");
                }
                else if (flag == 1)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "MsgBox", "<script>alert('充值卡不存在！');</script>");
                }
                else if (flag == 2)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "MsgBox", "<script>alert('充值卡已被使用！');</script>");
                }
                else if (flag == 3)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "MsgBox", "<script>alert('该充值卡没有被购买，不能够充值！');</script>");
                }
                else if (flag == 4)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "MsgBox", "<script>alert('充值失败！');</script>");
                }

            }
        }
        protected void ResetButton_Click(object sender, EventArgs e)
        {
            TextBox1.Text = "";
        }
    }
}